﻿using System.Collections.Generic;
using System.Windows;
using Microsoft.ApplicationServer.Caching;

namespace MDCAdminTool.Controls
{
    public partial class SearchDataCacheWin : Window
    { 
        public MdcCache Cache { get; set; }

        public SearchDataCacheWin()
        {
            InitializeComponent();
        }

        private void btnSearch_Click( object sender , RoutedEventArgs e )
        {
            if( Cache == null || string.IsNullOrEmpty(tbKey.Text) )
                return;

            var client = CacheClientFactory.GetCache(Cache);

            var result = client.GetCacheItem( tbKey.Text );

            if( result != null )
                dgResult.ItemsSource = new List<DataCacheItem>{ result };
        }
    }
}
